<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta charset="UTF-8">
    <title>test template</title>
    <script type="text/javascript" src="../static/template.js"></script>
</head>
<body>
<div id="content"></div>
<script type="text/html" id="test">
    {{if isAdmin}}
    <h1>{{title}}</h1>
    <ul>
        {{each list as value i}}
        <li>索引 {{digitalToLetter(i+1)}} : {{value}}</li>
        {{/each}}
    </ul>
    {{else}}
    <h1>{{title}}</h1>

    <ul>
        {{each list2 as value i}}
        <li>索引 {{i+1}} ：{{value}}</li>
        {{/each}}
    </ul>
    {{/if}}
</script>
<script type="text/javascript">
    var data = {
        title:'基本例子',
        isAdmin:true,
        list:['文艺','博客','摄影','电影','民谣','旅行','吉他'],
        list2:["体育",'跑步','篮球']
    };
    template.helper('digitalToLetter', function (i) {
        var num = 65 + i;
        var letter = String.fromCharCode(num);
        return letter;
    })
    var html = template('test',data);
    document.getElementById('content').innerHTML = html;
</script>
</body>
</html>